package com.idc;

import java.util.Date;
import java.util.Random;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import com.alibaba.fastjson.JSON;
import com.idc.common.cache.RedisClient;
import com.idc.quotation.entity.SystemUser;
import com.idc.quotation.service.SystemUserService;

@SpringBootApplication
public class TestApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context =
		SpringApplication.run(TestApplication.class, args);
		RedisClient redisClient = context.getBean(RedisClient.class);
		redisClient.set("ykx", System.currentTimeMillis() + "", 100);
		System.out.println("redis get======>" + redisClient.get("ykx"));
		SystemUserService service = context.getBean(SystemUserService.class);
		for (int i = 0; i < 10; i++) {
			SystemUser user = new SystemUser();
			user.setUsername("u_" + i);
			user.setAddress("address" + i);
			user.setAge(i);
			user.setSex(new Random().nextInt(2));
			user.setPhoneNumber(String.valueOf(13000000000L + i));
			user.setCreateTime(new Date());
			service.add(user);
		}
		System.out.println("max id:" + service.maxId());
		System.out.println("count:" + JSON.toJSONString(service.count()));
	}
}
